//
//  WXLSongsModel.m
//  段子手
//
//  Created by dllo on 16/3/19.
//  Copyright © 2016年 JokesTeam. All rights reserved.
//

#import "WXLSongsModel.h"

@implementation WXLSongsModel

- (instancetype)initWithDic:(NSDictionary *)dic {
    self = [super initWithDic:dic];
    if (self) {
        
    }
    return self;
}

- (void)setValue:(id)value forKey:(NSString *)key {
    [super setValue:value forKey:key];
    
    if ([key isEqualToString:@"favorites"]) {
        
        CGFloat f = [value floatValue];
        if (f >= 10000) {
            self.favorites = [NSString stringWithFormat:@"%.1f万", f / 10000];
        } else {
            self.favorites = [NSString stringWithFormat:@"%.0f", f];
        }
    }
    
    if ([key isEqualToString:@"songId"]) {
        self.songId = [value stringValue];
    }
    
    if ([key isEqualToString:@"mvList"]) {
        NSArray *arr = value;
        if (arr.count) {
            self.mvListUrl = arr[0][@"url"];
            self.mvListImg = arr[0][@"picUrl"];
            self.mvListDuration = [arr[0][@"duration"] floatValue] / 1000;
            self.videoId = arr[0][@"videoId"];
            CGFloat h = [arr[0][@"vertical"] floatValue];
            CGFloat w = [arr[0][@"horizontal"] floatValue];
            self.mvImageHeight =  ((kUIScreenWidth - 20) / 2) / (w / h);
        }
    }
    
    if ([key isEqualToString:@"picUrl"]) {
        NSString *str = value;
        if (!str.length) {
            self.picUrl = @"http://img.xiami.net/images/album/img80/78980/4142851382406916_4.jpg";
        } else {
            self.picUrl = str;
        }
    }
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    if ([key isEqualToString:@"urlList"]) {
        self.urlListArr = [WXLUrlListModel modelHandelWithArray:value];
    }
}

@end
